<script setup>

import {ref} from 'vue'

const num = ref('')
const result = ref('')
let r = parseInt(Math.random()*100+1);
console.log(r)
const guess = () => {

  if (num.value < r) {
    result.value = '猜小了'
  } else if (num.value > r) {
    result.value = '猜大了'
  } else {
    result.value = '猜对了'
  }

}
</script>

<template>
  <h1>猜数字练习</h1>
  <input type="text" placeholder="请输入一个数字" v-model="num">
  <button @click="guess">猜</button>
  <h4>结果是:{{ result }}</h4>
</template>

<style scoped>

</style>